﻿<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="/HR_SYSTEM/Styles/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="/HR_SYSTEM/Styles/admin-all.css" />
    <script type="text/javascript" src="/HR_SYSTEM/Scripts/jquery-1.7.2.js"></script>
    <script type="text/javascript" src="/HR_SYSTEM/Scripts/jquery-ui-1.8.22.custom.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/HR_SYSTEM/Styles/ui-lightness/jquery-ui-1.8.22.custom.css" />
    <script type="text/javascript" src="/HR_SYSTEM/Scripts/tip.js"></script>
    <script type="text/javascript">
    	function addUser(){
    		document.forms["form_add"].submit();
    	}
    	function createXMLHttpRequest() {
		var xmlHttp;
		try {
			return new XMLHttpRequest();
		} catch (e) {
			try {
				return new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					return new ActiveXObject("Micrsoft.XMLHTTP");
				} catch (e) {
					alter("无法识别您的浏览器，将会失去异步传输功能");
					throw e;
				}
			}
		}
	}

	function validate() {
		if (event.keyCode != 13 && event.keyCode != 38 && event.keyCode != 40) {
			/*获取xmlHttp对象  */
			var xmlHttp = createXMLHttpRequest();
			/*连接哪一个Servlet */
			xmlHttp.open("POST", "<c:url value='/ValidateUserName'/>", true);
			xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			var username = document.getElementById("username");
			xmlHttp.send("username=" + username.value);
			xmlHttp.onreadystatechange = function() {
				var message = document.getElementById("msg");
				if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
					var text = xmlHttp.responseText;
					if (text == "1") {
						message.innerHTML = "<font color='red'>员工已经被注册</font>";
					} else if (text == "2") {
						message.innerHTML = "<font color='blue'>请进行输入</font>";
					} else {
						message.innerHTML = "<font color='green'>名称可以被添加</font>";
					}
				}
			};
		}
	}
    </script>
</head>
<body>
    <div></div>
    <div class="alert alert-info">当前位置<b class="tip"></b>管理界面<b class="tip"></b>添加员工信息</div>
     <form action="<c:url value='/UserAddServlet'/>" name="form_add" method="post" enctype="multipart/form-data">
     <table class="table table-striped table-bordered table-condensed">
        <tr>
            <td>员工编号:</td>
            <td>自动生成</td>
        </tr>
        <tr>
            <td>员工姓名:</td>
            <td><input name="username" id="username" type="text" onpropertychange="validate()"/>&nbsp;&nbsp;&nbsp;&nbsp;<span id="msg"></span></td>
 		</tr>
 		<tr>
            <td>登陆密码:</td>
            <td><input name="password" id="password" type="password" /></td>
 		</tr>
        <tr>
            <td>员工部门:</td>
            <td>
            	<select name="dept_id">
            		<c:forEach items="${deptList}" var="dept">
            			<option value="${dept.dept_ID}">${dept.dept_NAME}</option>
            		</c:forEach>
            	</select>
            </td>
        </tr>
        <tr>
            <td>员工年龄:</td>
            <td><input name="age" id="age" type="text" /></td>
        </tr>
        <tr>
            <td>员工性别:</td>
            <td>
            	<label>
                	<input type="radio" checked="checked" name="sex" value="MALE" />男性
					<input type="radio" name="sex" value="FEMALE" />女性
				</label>
			</td>
        </tr>
        <tr>
            <td>员工状态:</td>
            <td>
                <label>
                	<input type="radio" checked="checked" name="state" value="1" />在职正常
					<input type="radio" name="state" value="0"/>离职休假
				</label>
            </td>
        </tr>
        <tr>
        	<td>员工照片：</td>
        	<td><input style="width: 223px; height: 20px;" type="file" name="photo"/><br/></td>
        </tr>
        <tr>
        	<td>员工档案：</td>
        	<td><input style="width: 223px; height: 20px;" type="file" name="file"/><br/></td>
        </tr>
        <tr>
        	<td>身份证号：</td>
        	<td><input name="verified_person" id="verified_person" type="text" /><br/></td>
        </tr>
        <tr>
        	<td>选择学历:</td>
        	<td>
        		<select name="education_record">
        			<option value="本科">本科</option>
        			<option value="硕士">硕士</option>
        			<option value="博士">博士</option>
        		</select> 
        	</td>
        </tr>
        <tr>
        	<td>填写学位</td>
        	<td><input type="text" name="degree"/></td>
        </tr>
        <tr>
            <td colspan="2">
                <input class="btn btn-inverse" id="button" type="button" onClick="addUser()" value="添加信息" />&nbsp;
                <input class="btn btn-inverse" type="reset" value="清空" />&nbsp;
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
